/*****
  ** @file     : hw_elec.c/h
  ** @brief    : 硬件电流控制器
*****/

#ifndef HW_ELEC_H
#define HW_ELEC_H

#ifdef __cplusplus
extern "C" {
#endif

//引用端口定义
#include "kernel_port.h"


//GPIO输出
#define Out_AP_H()        gpio_bit_set(HW_ELEC_AP_GPIO_Port, HW_ELEC_AP_Pin)
#define Out_AP_L()        gpio_bit_reset(HW_ELEC_AP_GPIO_Port, HW_ELEC_AP_Pin)
#define Out_AM_H()        gpio_bit_set(HW_ELEC_AM_GPIO_Port, HW_ELEC_AM_Pin)
#define Out_AM_L()        gpio_bit_reset(HW_ELEC_AM_GPIO_Port, HW_ELEC_AM_Pin)
#define Out_BP_H()        gpio_bit_set(HW_ELEC_BP_GPIO_Port, HW_ELEC_BP_Pin)
#define Out_BP_L()        gpio_bit_reset(HW_ELEC_BP_GPIO_Port, HW_ELEC_BP_Pin)
#define Out_BM_H()        gpio_bit_set(HW_ELEC_BM_GPIO_Port, HW_ELEC_BM_Pin)
#define Out_BM_L()        gpio_bit_reset(HW_ELEC_BM_GPIO_Port, HW_ELEC_BM_Pin)

/**
  * 线圈定义
**/
typedef struct{
    uint16_t conver;        //SIN数组指针
    int16_t  sin_data;    //SIN换算数值
    uint16_t dac_reg;        //12位DAC数值
}Coil_Typedef;

extern Coil_Typedef        coil_a;    //电流控制
extern Coil_Typedef        coil_b;    //电流控制

void REIN_HW_Elec_Init(void);                                                                                //硬件电流控制初始化
void REIN_HW_Elec_SetSleep(void);                                                                        //硬件电流设置驱动睡眠
void REIN_HW_Elec_SetBrake(void);                                                                        //硬件电流设置驱动刹车
void REIN_HW_Elec_SetDivideElec(uint32_t divide, int32_t elec_ma);    //硬件电流设置输出细分电流
void CurrentControl_VREF_12Bit_MixOut(uint16_t elec_va, uint16_t elec_vb);
#ifdef __cplusplus
}
#endif

#endif

